package ar.com.photo_admin.domain

import org.codehaus.jettison.json.*;
import org.springframework.security.web.WebAttributes
import mercadopago.*;

class IndexController {

	def messageService
	
	def index = {		
		
	}
	
	def addEvents = {
		render(view: "index", model: [showAddToken: true])
	}
	
	def login = {
		def redirectUrl = session.getAttribute(WebAttributes.SAVED_REQUEST)?.getRedirectUrl();
		render(view: "index", model: [showLogin: true, redirectUrl: redirectUrl])				
	}
	
	def forbidden = {
		
	}
	
	def about = {
				
	}
	
	def contactUs = {
	
	}	
	
	def contactMessage(){
		String subject = params.subject
		String body = params.message
		
		if (!subject)
			subject = message(code: "messages.no.subject")

		// TODO send message
						
		flash.message = message(code: "messages.sent.success")
		
		redirect(controller: "index", action: "contactUs")
	}
}
